<template>
  <section>
    <el-row>
      <el-col :span="6">
        <span style="font-size: 28px;">日常饮食</span>
      </el-col>
      <el-col :span="18" style="border:1px solid #666;padding:5px;">
        <el-row>
          ◎推荐主食:
          <span v-for="(fs,index) of widget.data.foodSuggest" :key="fs.id" style="font-weight: bold;">
            {{fs.name}}
            <section v-if="index < (widget.data.foodSuggest.length-1)">,</section>
          </span>
        </el-row>
        <el-row style="border-bottom:1px solid #000">
          ◎推荐食物：<span style="font-size: 14px;color:#aaa">({{widget.data.gongxiao}}等功效的食物，详见下表)</span>
        </el-row>
        <el-row style="border-bottom:1px dashed #000">
          <el-col :span="4" style="font-weight: bold">功效</el-col>
          <el-col :span="20" style="font-weight: bold">推荐食物</el-col>
        </el-row>
        <el-row v-for="ef of widget.data.foodEffect" :key="ef.id" style="border-bottom:1px dashed #000">
          <el-col :span="4">{{ef.name}}</el-col>
          <el-col :span="20">{{ef.recommendedFood}}</el-col>
        </el-row>
        <el-row style="border-top: 1px solid #000;">
          ◎不宜食用：{{widget.data.foodSuggestWithout}}
        </el-row>
      </el-col>
    </el-row>
  </section>
</template>

<script>
  export default {
    name: "page-fangan-b",
    props: ['reportData','widget', 'showConfDialog'],
    created(){
      //this.widget.data.zhushi = '糙米'
      if(Object.getOwnPropertyNames(this.widget.data).length < 4){
        this.widget.data.foodSuggest = this.reportData.data.foodSuggest
        this.widget.data.foodSuggestWithout = this.reportData.data.foodSuggestWithout
        this.widget.data.foodEffect = this.reportData.data.foodEffect
        //组装所有功效
        this.widget.data.gongxiao = ''
        for(let i=0;i<this.reportData.data.foodEffect.length;i++){
          this.widget.data.gongxiao += this.reportData.data.foodEffect[i].name
          if(i < this.reportData.data.foodEffect.length-1)
            this.widget.data.gongxiao += '、'
        }
        this.$emit('done',this.widget.data)
      }
    }
  }
</script>

<style scoped>

</style>
